package com.ewzj.bigdata.mvp.ui.adapter

import android.content.Intent
import android.text.TextUtils
import android.view.View
import android.widget.ImageView

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.ewzj.bigdata.R
import com.ewzj.bigdata.app.config.AppKey
import com.ewzj.bigdata.app.extensions.loadImgwithloading
import com.ewzj.bigdata.mvp.model.rspbean.DecCompanysBeans
import com.ewzj.bigdata.mvp.ui.activity.WebViewActivity
import com.jakewharton.rxbinding2.view.RxView
import com.jess.arms.utils.UiUtils
import io.reactivex.functions.Consumer

/**
 * author:zhangjing
 * 作用:
 * return:
 */

class NewItemdecCompanyAdapter(data: List<DecCompanysBeans.ListEntity>) : BaseQuickAdapter<DecCompanysBeans.ListEntity, BaseViewHolder>(R.layout.item_newdeccompany, data) {

    override fun convert(baseViewHolder: BaseViewHolder, deccompany: DecCompanysBeans.ListEntity) {
        baseViewHolder.getView<ImageView>(R.id.iv_tmp).loadImgwithloading(deccompany.thumb)
        baseViewHolder.setText(R.id.tv_name, deccompany.comp_name)
        baseViewHolder.setText(R.id.tv_source, if (deccompany.sources != null) "来源•" + deccompany.sources else "来源•觅窝")
        baseViewHolder.setText(R.id.tv_rate, if (TextUtils.isEmpty(deccompany.favor_rate)) "好评率100%" else "好评率" + deccompany.favor_rate)
        RxView.clicks(baseViewHolder.convertView).subscribe(Consumer {
            var intent=Intent(mContext,WebViewActivity::class.java)
            intent.putExtra(AppKey.EXTRA_url,deccompany.go_url)
            intent.putExtra(AppKey.EXTRA_String,deccompany.comp_name)
            mContext.startActivity(intent)
        })
    }

}
